package com.liuxin.zhiyuan.shujuzhongxin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liuxin.zhiyuan.shujuzhongxin.domain.po.HistoricalAdmissionScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
 * 院校专业招生信息表
 * 
 * @author zsl
 * @email 1301966496@qq.com
 * @date 2025-11-08 22:16:26
 */
@Mapper
public interface HistoricalAdmissionScoreMapper extends BaseMapper<HistoricalAdmissionScoreEntity> {
    /**
     * 根据位次查询对应的分数
     */
    @Select("SELECT score FROM lxzy_score_segment WHERE year = #{year} AND subject_type = #{subjectType} AND cumulative_count >= #{rank} ORDER BY cumulative_count ASC LIMIT 1")
    Integer findScoreByRank(@Param("year") Integer year,
                            @Param("subjectType") String subjectType,
                            @Param("rank") Integer rank);


    @Select("select round(avg(low_rank)) from lxzy_historical_admission_score where school_id=#{schoolId} and nature = #{nature} and year ='2024' and pro in (SELECT pro from lxzy_recruit_major_info where school_code = #{schoolCode}) and low_rank <> 0 and low_score <> 0 ")
    Integer findSchoolCodeAverageRank(@Param("schoolId") Integer schoolId, @Param("schoolCode") String schoolCode,@Param("nature") String nature);

}
